package main

import (
	"fmt"
)

func main() {

	s6 := []int{4, 6, 3}
	fmt.Println(s6)
	fmt.Printf("len:%d,cap:%d\n", len(s6), cap(s6))
	fmt.Printf("%p\n", s6) //打印内存地址

	s6 = append(s6, 2, 3)
	fmt.Println(s6)
	//len:5,cap:6  长度加对应个数  容量乘2
	fmt.Printf("len:%d,cap:%d\n", len(s6), cap(s6))
	fmt.Printf("%p\n", s6) //打印内存地址
	fmt.Println("============底层分析============")
	//底层分析
	numbers := []int{2, 4, 6, 7}
	fmt.Println(numbers)

	//创建切片
	numbers1 := make([]int, len(numbers), (cap(numbers))*2)

	//将numbers中的数拷贝到numbers1
	copy(numbers1, numbers)

	fmt.Printf("len: %d cap: %d slice%v   ", len(numbers1), cap(numbers1), numbers1)
}
